<?php

namespace app\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
 * This is the model class for table "showorder".
 *
 * @property integer $showid
 * @property string $uname
 * @property string $uimg
 * @property integer $order_id
 * @property integer $auction_id
 * @property integer $product_id
 * @property integer $user_id
 * @property string $content
 * @property integer $created_at
 * @property integer $updated_at
 * @property Showpic[]  $showpics
 */
class Showorder extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'showorder';
    }
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes'=>[
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
                ],
            ]
        ];
    }
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uname', 'uimg', 'auction_id', 'product_id', 'user_id', 'content','order_id'], 'required'],
            [['auction_id', 'product_id', 'user_id'], 'integer'],
            [['uname', 'uimg', 'content'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'showid' => '晒单id',
            'uname' => '用户名',
            'uimg' => '用户头像',
            'order_id'=>'订单id',
            'auction_id' => '竞拍id',
            'product_id' =>'产品id',
            'user_id' => '用户id',
            'content' => '内容',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
        ];
    }

    public function getShowpics()
    {
        return $this->hasMany(Showpic::className(),['show_id'=>'showid']);
    }
}
